package com.dhnsoft;

public class 回文 {
    public static void main(String[] args) {
        double log = Math.log10(2);
//        System.out.println((int)log);
        String s = "MCMXCIV";
        s = s.replace("IV","a");
        s = s.replace("IX","b");
        s = s.replace("XL","c");
        s = s.replace("XC","d");
        s = s.replace("CD","e");
        s = s.replace("CM","f");
        char[] chars = s.toCharArray();
        int result = 0;
        for (char aChar : chars) {
            if(aChar=='I') result+=1;
            else if(aChar=='V') result+=5;
            else if(aChar=='X') result+=10;
            else if(aChar=='L') result+=50;
            else if(aChar=='C') result+=100;
            else if(aChar=='D') result+=500;
            else if(aChar=='M') result+=1000;
            else if(aChar=='a') result+=4;
            else if(aChar=='b') result+=9;
            else if(aChar=='c') result+=40;
            else if(aChar=='d') result+=90;
            else if(aChar=='e') result+=400;
            else if(aChar=='f') result+=900;
        }
        System.out.println(result);
    }
}
